Skip to content

refactor: simplify async timer logic #3028

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Nov 5, 2021
Merged

Conversation

dariakp
Copy link
Contributor

@dariakp dariakp commented Nov 5, 2021

Description

What is changing?

Simplifying the logic so that we can reason more easily about the async scheduler.

The previous code was relying on the NaN timeSinceLastWake correctly falling through on first wake, this refactor makes it so we rely on a more straightforward boolean cannotBeExpedited instead.

Updating tests to use synchronous assertions since sinon fake timers don't require async callbacks to execute.

Is there new documentation needed for these changes?

No

What is the motivation for this change?

Hopefully reduce chance of accidental bugs

Double check the following

  • Ran npm run check:lint script
  • Self-review completed using the steps outlined here
  • [N/A] PR title follows the correct format: <type>(NODE-xxxx)<!>: <description>
  • Changes are covered by tests
  • [N/A] New TODOs have a related JIRA ticket

@dariakp dariakp requested review from durran and nbbeeken November 5, 2021 02:08
Copy link
Member

@durran durran left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice job to make this more clear - it was definitely driving me crazy as well to figure out what was going on in the original code. I like the use of multiple assertions here on the call counts as the code is stepped through.

Copy link
Contributor

@nbbeeken nbbeeken left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM with a CI run to double check, thanks for this!

@dariakp
Copy link
Contributor Author

dariakp commented Nov 5, 2021

@dariakp dariakp merged commit e425b7e into NODE-3116 Nov 5, 2021
@dariakp dariakp deleted the NODE-3116-alternate-timers branch November 5, 2021 13:49
Copy link
Contributor

@nbbeeken nbbeeken left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CI -> ✅

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants